home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Light ROM 1
/
LIGHT-ROM 1 (Amiga Library Services)(1994).iso
/
ffdisks
/
d939.lha
/
ExtraCmds
/
source_etc.lha
/
src
/
severalnames.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-22
|
3KB
|
86 lines
/* --------------------------------- -------
* |\ | | | | | |.| | \| |/ /|\ |||||||
* | | | |/ | |\ |/ |/| |\ |/ | ? ---+--- =<
* | | | | | | | | | | | \qqqqqqqqq/
* --------------------------------- ~~~~~~~~~~~~~~~~
*
* severalnames() - A hack to determine if more than one name is
* specified for a /M argument. The presence of
* a pattern is taken to mean that there is more
* than one name (even if it doesn't match anything!)
*
* Doesn't report a malformed pattern, as it will be
* caught by a subsequent call to a pattern matching
* function like foreach().
*
* Copyright (C) 1993 Torsten Poulin
*
* This file is part of "Torsten's AmigaDOS Shell Commands" package.
* The package is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* The author can be contacted by s-mail at
* Torsten Poulin
* Banebrinken 99, 2, 77
* DK-2400 Copenhagen NV
* DENMARK
*
* $Id: severalnames.c,v 1.2 93/03/01 13:02:22 Torsten Rel $
* $Log: severalnames.c,v $
* Revision 1.2 93/03/01 13:02:22 Torsten
* Changed all occurrences of "struct DosBase *" to "struct DosLibrary *"
*
* Revision 1.1 93/03/01 11:04:48 Torsten
* Initial revision
*
*/
#include <exec/types.h>
#include <exec/memory.h>
#include <dos/dos.h>
#include <dos/dosasl.h>
#include <clib/dos_protos.h>
#include <clib/exec_protos.h>
#ifdef __SASC
#include <pragmas/dos_pragmas.h>
#include <pragmas/exec_pragmas.h>
#endif
#include <string.h>
#include "tastlib.h"
struct Global {
struct DosLibrary *DOSBase;
};
ULONG severalnames(UBYTE **arg, VOID *global)
{
struct DosLibrary *DOSBase = ((struct Global *) global)->DOSBase;
UBYTE *dest;
UBYTE **args;
ULONG several = 0L;
ULONG length;
args = arg;
for (; *args; args++, several++)
if (several)
return TRUE;
length = 2 * strlen(*arg) + 2;
if (!(dest = AllocVec(length + 1, MEMF_PUBLIC)))
several = ERROR_NO_FREE_STORE;
several = ParsePattern(*arg, dest, length) > 0 ? TRUE : FALSE;
FreeVec(dest);
return several;
}